#include "binomialnode.h"

BinomialNode::BinomialNode(double val):
        Node(val)
{
    pNode = -1;
    nNode = -1;    
}

BinomialNode::BinomialNode(QString lbl, double val, double sd, Node * pNode, Node * nNode, bool observed):
        Node(lbl, val, sd, observed)
{
    setPNode(pNode);
    setNNode(nNode);    
}

bool BinomialNode::inRange(double v)
{
    return 0.0 == v || v == 1.0;
}

void BinomialNode::setPNode(Node * node)
{
    pNode = addParentNode(node);
}

void BinomialNode::setNNode(Node * node)
{
    nNode = addParentNode(node);
}

double BinomialNode::computeLogLikelihood()
{
    return VALID_LOG(gsl_ran_binomial_pdf(this->getValue(),
                                    parents->at(pNode)->getValue(),
                                    parents->at(nNode)->getValue())
                     );
}

